package no.ntnu.item.ttm4115.termproject.playerpositionagent;

import no.ntnu.item.ttm4115.termproject.PositionAgentAddressFromPlayerAgent;
import no.ntnu.item.ttm4115.termproject.ManuallyPosition;
import no.ntnu.item.ttm4115.termproject.GetPositionManually;
import no.ntnu.item.ttm4115.termproject.Position;
import no.ntnu.item.ttm4115.termproject.AutoPosition;
import no.ntnu.item.ttm4115.termproject.GetPositionAuto;
import no.ntnu.item.ttm4115.termproject.PositionToGroupAgent;
import no.ntnu.item.ttm4115.termproject.DistributePosition;


public class PlayerPositionAgentActions extends Object {

	public static void startUp(PositionAgentAddressFromPlayerAgent signal, PlayerPositionAgentSM asm){
		asm.groupAgentAddress = signal.groupAgentAddress;
		asm.positionAgentAddress = signal.PositionAgentAddress;
		asm.myPlayerName = signal.myPlayerName;
	}

	public static void getPosition(ManuallyPosition signal, PlayerPositionAgentSM asm){
	    // TODO edit action statements
		asm.currentGame = signal.gameGUI;
	asm.sendMessage(new GetPositionManually(), asm.positionAgentAddress);
	}

	public static void AskForAutoPosition(AutoPosition signal, PlayerPositionAgentSM asm){
	    // TODO edit action statements
	asm.sendMessage(new GetPositionAuto(), asm.positionAgentAddress);
	}

	public static void updatePositionToGUI(Position signal, PlayerPositionAgentSM asm){
	    // TODO edit action statements
		double latsend = signal.lat/100;
		double lonsend = signal.lon/100;
		
			asm.currentGame.updateManCoord(lonsend, latsend);
			
			
	asm.sendMessage(new PositionToGroupAgent(signal.lat,signal.lon,asm.myPlayerName), asm.groupAgentAddress);
	}

	public static void updateOtherPlayersPosition(DistributePosition signal, PlayerPositionAgentSM asm){
		double latsend = signal.lat/100;
		double lonsend = signal.lon/100;
		if(!(signal.playerName.equals(asm.myPlayerName))){
	    	System.out.println("her skal det skrives ut posisjonen til andre spillere.....");
	    	System.out.println("pos ="+signal.lat+","+signal.lon);
	    	
	    	
	    }
	    asm.currentGame.updateOtherCoord(lonsend, latsend, signal.playerName);
	}



}
